const http = require('http')
const Koa = require('koa')
const koaBody = require('koa-body')

const app = new Koa()

app.on('error', (err, ctx) => {
  console.error('server error', err, ctx)
})

app.use(
  koaBody({
    multipart: true,
    formidable: {
      maxFileSize: 2000 * 1024 * 1024, //文件大小限制
    },
  })
)

app.use(async (ctx, next) => {
  await next();
  console.log(ctx.request.body)
  ctx.response.body = 'Hello, koa2!';
});



const server = http.createServer(app.callback())

app.on('error', (err, ctx) => {
  console.error('server error', err, ctx)
})

server.listen(3030)
